<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Activity extends Model {
	protected $table = "activitys";

	protected $fillable = [
		'product', 'name', 'days', 'image',
	];

	public function business() {
		return $this->belongsToMany(Business::class, 'activityables');
	}

	public function types() {
		return $this->belongsToMany(Type::class, 'activityables')->withTimestamps()->withPivot('id', 'business_id');
	}

	public function maps() {
		return $this->hasMany(Map::class);
	}

	public function orders() {
		return $this->hasManyThrough(Order::class, Activityable::class, 'activity_id', 'map_id');
	}
}
